import ReactDOM from 'react-dom'
import React, { Component } from 'react'

class App extends Component {

  state = {
    count: 0
  }

  add = () => {
    this.setState({ count: this.state.count + 1 }, () => {
      console.log('回调函数', this.state.count)
    })
    console.log(this.state.count)
  }

  render() {
    console.log('render')
    return (
      <div className='app'>
        <div>计数器：{this.state.count}</div>
        <button onClick={this.add}>+1</button>
      </div>
    )
  }
}


ReactDOM.render(<App />, document.getElementById('root'))